﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Media;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.IO;

namespace HotelBookingSystem.DataBaseStuff
{
    class MyRandom
    {
        public static int RanNum(int min, int max)
        {
            max++;
            //int gg = (DateTime.Now.Millisecond);
            //Random random = new Random();//
            Random random = RandomProvider.GetThreadRandom();
            int ran = random.Next(min, max);

            return ran;
        }
        public static int[] RanNum(int min, int max, int arraySize)
        {
            //Thread.Sleep(2);
            max++;
            int[] ran = new int[arraySize];
            //int gg = (DateTime.Now.Millisecond);
            //Random random = new Random();//
            Random random = RandomProvider.GetThreadRandom();
            for (int l = 0; l < arraySize; l++)
                ran[l] = random.Next(min, max);

            return ran;
        }
        //random Provider somewhere on the net
        public static class RandomProvider
        {
            private static int seed = Environment.TickCount;

            private static ThreadLocal<Random> randomWrapper = new ThreadLocal<Random>(() =>
                new Random(Interlocked.Increment(ref seed))
            );

            public static Random GetThreadRandom()
            {
                return randomWrapper.Value;
            }
        }
    }
}